Skip to content

Enterprise/feature hardening#43

Merged
layer78 merged 3 commits intomainfrom
enterprise/feature-hardening
Apr 8, 2026
Merged

Enterprise/feature hardening#43
layer78 merged 3 commits intomainfrom
enterprise/feature-hardening

Conversation

@layer78
Copy link
Copy Markdown
Collaborator

@layer78 layer78 commented Apr 8, 2026

No description provided.

Rishi Yadav added 3 commits April 8, 2026 10:32
…ure overhaul

Security:
- Slow-loris defense with per-connection byte/time budgets
- HTTP request smuggling detection (reject TE + Content-Length)
- Keyed SipHash via RandomState for hash-flooding resistance
- Session hardening: HMAC-SHA256 signed cookies, LRU eviction,
  max_data_size guard, constant-time signature comparison
- Rate limiter bounded to 100K entries with two-pass LRU eviction
- Security headers middleware (helmet) — 11 pre-computed headers
- Request ID middleware for end-to-end correlation

Performance:
- Zero-heap-alloc route matching with ArrayVec (stack-allocated params)
- Header name interning — top 20 headers by length-first branching
- Clone elimination in cache key interpolation (direct slice pass)
- Dual-lane FNV-1a hash for fast static-route lookup
- AST-based handler analysis (acorn) with regex fallback for
  zero-copy access plans — skip materializing unused request fields
- Compressed static route responses (Brotli + Gzip pre-built at startup)

Architecture:
- Extracted parser.rs, response.rs, http_utils.rs from monolithic lib.rs
- Structured log macros (hn_info!, hn_warn!, hn_error!, hn_debug!)
- HTTP response builder consolidated in response.rs

DX & API:
- Full TypeScript declarations for all public APIs and sub-modules
- app.head() method registration
- app.health() convenience API (Rust static fast-path, zero JS dispatch)
- res.redirect() on response prototype
- Session, helmet, request-id, compress type exports in package.json
- session.d.ts with SessionStore, MemoryStore, RedisStore types
…otocol improvements

Security:
- Fix session fixation (regenerate ID on privilege change) and data size bombing
- Add slow-loris protection via header-phase wall-clock deadline
- Fix body-limit bypass (enforce actual body size, not just Content-Length)
- Guard probeHandlerForFastPath against side-effect leaks during compilation

Functionality:
- Fix response status access across audit-log, logger, otel (res._state.status)
- Fix CORS Vary header append (was overwriting)
- Make OpenAPI middleware functional (was no-op) — serves spec JSON and Swagger UI
- Make otel flushSpans() functional (was no-op)
- Fix TLS config override — explicit null now properly disables TLS
- Fix error handler access plans (no longer breaks all routes to generic_fallback)
- Fix AST analyzer to detect destructuring from req (const { query } = req)
- Add H3 handler fallback for malformed static responses
- Scope keep-alive timeout variable per request cycle (eliminates dead assignment)
- Restrict h2_handler visibility to pub(crate)

New middleware:
- audit-log, body-limit, circuit-breaker, csrf, env, error, ip-filter,
  logger, multipart, openapi, otel

TypeScript:
- Fix session types, route method overloads, loadEnv mapped type, otel types
- Add comprehensive type definitions for all new middleware

Build:
- 0 compiler warnings (was 4)
- Gitignore planning files (PLAN.md, boost.md, dx.md)
bridge.js imports acorn for AST-based handler analysis but it was not
declared in package.json, causing CI to fail on clean install.
@layer78 layer78 merged commit accc200 into main Apr 8, 2026
1 check passed
@layer78 layer78 deleted the enterprise/feature-hardening branch April 8, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant